<?php
header('content-type:text/html;charset=utf-8');
include('common.php');
include(S_ROOT.'source/class_curl.php');

$op = isset($_GET['op']) ? trim($_GET['op']) : 'index';
set_time_limit(100);
$account = array(
	'username' => 'mancy_photo',
	'password' => '3.1415926535'
);
switch($op)
{
	case 'index':
	
		if(empty($_POST)){
			$yahoo = new Curl('yahoo', $account, false);
			$html = $yahoo->get('https://www.yahoo.co.jp', '', 'euc-jp');
			exit($html);
			$html = $yahoo->get('https://login.yahoo.co.jp/config/login?.src=auc&.pd=&.done=http%3A//auctions.yahoo.co.jp/', '', 'euc-jp');
			preg_match('/<input type=\"hidden\" name=\"\.albatross\" value=\"(.+?)\">/is',$html,$albatross);
			preg_match('/<input type=\"hidden\" name=\"\.u\" value=\"(.+?)\">/is',$html,$u);
			preg_match('/<input type=\"hidden\" name=\".challenge\" value=\"(.+?)\">/is',$html,$challenge);

			//exit($html);

			$postDate = array(
				'url' => 'https://login.yahoo.co.jp/config/login?',
				'referer' => 'https://login.yahoo.co.jp/config/login?.src=auc&.pd=&.done=http%3A//auctions.yahoo.co.jp/',
				'data' => ".ct=&.albatross={$albatross[1]}&.tries=1&.src=auc&.md5=&.hash=&.js=&.last=&promo=&.intl=jp&.bypass=&.partner=&.u={$u[1]}&.v=0&.challenge={$challenge[1]}&.yplus=&.emailCode=&pkg=&stepid=&.ev=&hasMsgr=0&.chkP=Y&.done=http%3A%2F%2Fauctions.yahoo.co.jp%2F&.pd=&.protoctl=&login={$account['username']}&passwd={$account['password']}&.persistent=y",
			);
			//print_r($postDate);
			
			$html = $yahoo->post($postDate, '', 'euc-jp');
			
			//exit($html);
			preg_match_all('/<input.+?name=\"(.+?)\".+?value=\"(.*?)\"[^>]*>/is',$html,$inputs);
			preg_match('/<div class="captcha_box">(.+?)<\/div>/is',$html,$captcha);
		
			if($inputs[1]){
				
				$data = '';
				foreach($inputs[1] as $key => $val){
					$data .= "{$val}={$inputs[2][$key]}&";
					$data = urldecode($data);
				}

				//需要验证码
				
				
			
			}
		}else{
			$captchaAnswer = isset($_POST['captchaAnswer']) ? trim($_POST['captchaAnswer']) : '';
			$data = isset($_POST['data']) ? trim($_POST['data']) : '';
			
			$postDate = array(
					'url' => 'https://login.yahoo.co.jp/config/login',
					'data' => ".src=auc&.done=http%3A%2F%2Fauctions.yahoo.co.jp%2F&.challenge=dR3jLRz_NktbmjcchdqG7ePt7up0&.v=0&validate=validate&captchaCdata=ws__Ut1aF1NN2R73bRk9YGaOD_dWexNQbc8M3Ocp_e7hPb7Go0._Q0Oa3V2frhC5xuDbb2iemr17g--&captchaMultiByteCaptchaId=ws_sqbXqAQjOmyAwU_EPjMhrDcgU8D.UBsmMb_241weWeobBgMtG_r.JRCieSNGJSjfMuYDlU8g7tdDFYyki2d5vHfar3EOH7ZgxUjleRwHm35M5Goylatx.NyfSTpQPD8-&captchaView=visual&captchaClassInfo=ws_VLcN2nJNPX1o.tg9NyEzJyohIM6X63eb9laLGpHGqUpWmyvqeVGGWyOA6yICIw7s3H51HfmowmqwIA--&.sectry=0&captchaAnswer=%A4%CA%A4%F3%A4%C6%A4%AA%A4%C4%A4%AB&x=79&y=14",			
				);
				//print_r($postDate);exit;
				
			$captchaV5Answer = $letian->post($postDate,'(id=\"captchaV5Answer\")', 'euc-jp');
			
		}
	break;

	
}